package com.dyz.swordFingerOffer;

import java.util.Stack;

/**
 * @author: daiyizheng
 * @date: 2021/5/29 16:00
 * @description:
 */
public class Queue09 {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        //插入元素
        //stack1 作为保存 底部存新插入的元素， 顶部存老元素
        while(!stack1.isEmpty()){
            stack2.push(stack1.pop());
        }
        stack1.push(node);

        while(!stack2.isEmpty()){
            stack1.push(stack2.pop());
        }
    }

    public int pop() {
        if(stack1.isEmpty()){
            return -1;
        }

        return stack1.pop();
    }
}
